home *** CD-ROM | disk | FTP | other *** search
- Path: goanna.cs.rmit.EDU.AU!not-for-mail
- From: ok@goanna.cs.rmit.EDU.AU (Richard A. O'Keefe)
- Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2
- Subject: Re: Hungarian notation
- Date: 6 Feb 1996 10:16:21 +1100
- Organization: Comp Sci, RMIT, Melbourne, Australia
- Message-ID: <4f6345$jll@goanna.cs.rmit.EDU.AU>
- References: <4cud8f$gup@news.netvision.net.il>
- NNTP-Posting-Host: goanna.cs.rmit.edu.au
- NNTP-Posting-User: ok
- X-Newsreader: NN version 6.5.0 #0 (NOV)
-
- Douglas Evan Cook <cookd@cs.byu.edu> writes:
- >Ah, but the ADT *did* specify that the file format would remain the
- >same.
-
- There seems to be some confusion here.
-
- A file format is a *concrete* data type.
-
- It is possible to hide the details by writing an ADT.
-
- >And not all users of the applications are using the same platforms
- >- some are running on 386's with 386 DOS extenders, some are running with
- >286 extenders, some are running on overlaid versions of the program done
- >for straight DOS, some are running on Windows NT, and some are running on
- >non Intel based machines.
-
- There are three aspects here.
-
- (a) Portability of code.
- If programs access the file(s) in question _only_ through the ADT
- (which hides the file format), then the ADT has to be reimplemented
- for different file formats, but the rest of the programs port with
- no change.
-
- (b) Portability of data.
- I would really like to see you port a data file containing binary coded
- floating-point numbers from a 386 to a 680x0, PowerPC, SPARC, &c.
- Now you might think that straight "strings" can be ported with no
- trouble, but even that is hard. If your data were written on a
- machine using IBM Code Page 437 and read on a machine using
- Code Page 850, you had *better* use a conversion, same hardware or not!
-
- This is a serious issue. Almost weekly I run into text files that have
- had their end of line convention converted {CR, LF, CR-LF} but not the
- text characters.
-
- (c) Access to one copy of data in a heterogeneous network
- You cannot realistically do this without hiding the file format.
- XDR is _the_ big player here, and NetCDF is of great interest.
- Typically, on-the-fly conversion is a fraction of the cost
- of I/O across the network.
-
- >The users expect to be able to transfer files between each platform.
- >And so we compile, but in each platform we don't
- >want to have to modify the ADT's because of compiler dependancies. So we
- >have the ADT's depend on typedef equivalents, so that when we need to
- >compile for a new platform we only need to change 10-12 lines in the base
- >definition file.
-
- You keep on using "ADT" in a very puzzling way.
- It would clarify things a lot if you would _show_ us these 10-12 lines.
- If, as I suspect, it consists of things like
- typedef unsigned short u16;
- then you are _not_ dealing with ABSTRACT data types at all, and
- I have some bad news for you.
-
- Suppose I have a file format in which one field is specified to be a
- 16-bit little-endian unsigned integer.
- (a) I have used a really wonderful machine in which there was no such
- thing as an unsigned integer.
- (b) I have used several machines in which there was no such thing as
- a 16-bit storage format.
- (c) Many of the machines I have used require "natural" alignment, e.g.
- K-byte entities must have addresses that are multiples of K, for
- K = 1, 2, 4, 8. On an 80*86, you might not have thought of this,
- as that architecture supposed unaligned load/store.
- (d) I am using a terminal emulator on one machine to post from another.
- Neither of those machines is little-endian. (Which is a pity. I
- like little-endian, and feel that the image of little-endian has
- been tarnished by association with Intel.)
-
- What I am saying is that _if_ your program is like this:
-
- typedef <something> u16;
-
- u16 x;
- fwrite(&x, sizeof x, 1, output_stream);
- ...
- fread(&x, sizeof x, 1, input_stream);
-
- then there is literally no possible typedef on the Mac (68040) or Sun (SPARC 8)
- that I am using that could make this work with a data file written on an 80*86.
-
- By the way, if I wanted to read and write byte streams encoding numbers,
- arrays, and records, in Ada I would need *no* variation from platform to
- platform at all, not even 10-12 lines. Done right, that is.
-
- >> A clean way to deal with this would be to convert the data files. Done
- >> properly, this wouldn't inconvenience users.
-
- This conversion can be done when a file is moved to a different machine
- (which permits the use of "native" data representations in the file,
- but gets in the way of cross-network sharing)
- or it can be done whenever the file is accessed
- (which permits cross-network sharing, but not the use of "native"
- data representations in the file).
-
- Note, by the way, that there is no requirement for two compilers for language
- X on machine Y to represent basic data types the same way. (For example,
- C's "long double" might be stored in 80 bits, 96 bits, or 128 bits, all
- depending on which compiler you use.) On one of the machines I used, the
- vendor introduced long double with 96 bits, then switched over to 128. Any
- data files depending on 96 bit format would have been a pain to deal with...
-
- --
- "conventional orthography is ... a near optimal system for the
- lexical representation of English words." Chomsky & Halle, S.P.E.
- Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.
-